package com.cskaoyan.tcp.exercise.first;

import java.io.*;
import java.net.Socket;

/*
     客户端键盘录入，服务器输出到控制台
 */
public class Client {
    public static void main(String[] args) throws IOException {

        // 准备用于接收键盘录入的字符流
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        // 创建Socket对象
        Socket socket = new Socket("localhost", 9090);

        // 获取流
        OutputStream out = socket.getOutputStream();
        OutputStreamWriter writer = new OutputStreamWriter(out);

        String line;
        while ((line = br.readLine()) != null) {
            // 发送键盘录入的一行数据
            writer.write(line);
            writer.flush();
        }


        socket.close();
    }
}
